<?php
// No direct access
defined('_JEXEC') or die;

$defaultFields = $this->tableDefaultFields;
$fields = $this->tableFields;

$fieldId = array_shift($defaultFields);

$genmFields = $this->genmFields;

//$arrFieldsIgnore = array('state', 'ordering', 'checked_out', 'checked_out_time', 'created', 'created_by', 'modified', 'modified_by', 'metakey', 'metadesc');

$formFields = $this->item->form_fields;
?>

<style>
<!--
ul#form-elements li {
	width: 800px;
} 

ul#form-elements li label {
	float: left;
}

ul#form-elements li span {
	float: left;
	line-height: 23px;
}
-->
</style>

<ul id="form-elements">
	<?php 
	$i = 0;
	if(is_array($fields)):
		foreach ($fields as $field): ?>
		
		<li style="float: left; margin: 0; padding: 0; width: 800px;">
			<label><?php echo $field->name; ?></label>
			<select id="field_<?php echo $i; ?>" name="field[<?php echo $field->name; ?>][type]" field="<?php echo $field->name; ?>" class="form-field-type">
				<option value="">- Do not use -</option>
				<?php
				foreach ($this->element_types as $type => $option):
				
					$checked = '';
					
					foreach ($formFields as $formField)
					{					
						if ($formField->field_type == $type && $formField->field_name == $field->name)
						{
							$checked = 'selected="selected"';
							break;
						}
					}
				?>
				
				<?php $disabled = ($type == '-') ? 'disabled="disabled"' : null; ?>
				<option value="<?php echo $type; ?>" <?php echo $disabled; ?> <?php echo $checked; ?>>
					<?php echo $option['title']; ?>
				</option>
				<?php endforeach; ?>
			</select>
			<label>&nbsp;</label>
			<span style="float: left;"></span>
		</li>
		<?php $i ++; ?>
	<?php 
		endforeach; 
	endif;
	?>
	<?php if($i === 0): ?>
	<li>
		No field to select
	</li>
	<?php endif; ?>
</ul>